home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 112 / EnigmaAmiga112CD.iso / dalla rivista / awnpipe / awnp / awnp-docs / sbys.doc < prev    next >
Text File  |  1999-11-10  |  6KB  |  135 lines

  1. Understanding the conversation is the key to building GUIs with AWNP. Here is a walk through the creation and use of a simple example.
  2.  
  3.   Open the file AWNPipe:myGUI/xc. myGUI can be any name you want.The /xc must be used as it tells AWNPipe this file is for GUi creation. From now on I will refer to this file as the 'pipe'
  4.  
  5. Write a Window definition line to the pipe.
  6. 'title "My First gui" defaultgadgets'
  7. The line read from the pipe should be
  8. 'ok window'
  9. Anything else is an error response.
  10.  
  11. Write a Gadget definition line to the pipe. 
  12. 'button gadgettext "testbutton"
  13. The line read from the pipe should be
  14. 'ok 1'
  15. The Gadget ID of the button is 1. If the response line does not start with 'ok' then an error has occurred.
  16.  
  17. Write a Gadget definition line to the pipe. 
  18. 'checkbox gadgettext "tryme"
  19. The line read from the pipe should be
  20. 'ok 2'
  21. The Gadget ID of the checkbox is 2. If the response line does not start with 'ok' then an error has occurred.
  22.  
  23.  
  24. Write open command line to the pipe.
  25. 'open'
  26. The line read from the pipe should be
  27. 'ok window'
  28. Anything else is an error response.
  29.  
  30. Now you read an event from the pipe. It will come when the user selects a gadget. 
  31.  
  32. If the checkbox is selected you get the line
  33. 'gadget 2 1'
  34. the first word 'gadget tells you the event was from a gadget being hit. 2 is the gadgets GID, the 1 at the end tells you the checkbox is now selected.
  35.  
  36. If the checkbox is selected a second time you get the line
  37. 'gadget 2 1'
  38. the first word 'gadget tells you the event was from a gadget being hit. 2 is the gadgets GID, the 0 at the end tells you the checkbox is now unselected.
  39.  
  40. If the button is selected you get the line
  41. 'gadget 1 0'
  42. the first word 'gadget tells you the event was from a gadget being nit. 1 is the gadgets GID, the 0 at the end tells you the button is not highlighted. In this example you can ignore the 0 (button state).
  43.  
  44. when the GUI window is closed you get the line
  45. 'close 0'
  46. the first word 'close' tells you the event was from the window being closed. 0 (close source) tells you it closed when the close gadget was hit. If the user entered <CTRL\>' the close source would be -1. After the close event any further attempts to read the pipe will return EndOfFile.
  47.  
  48. You keep reading events until the end of file is received. You could also close the pipe after the close event is read. 
  49.  
  50.  
  51. This is a second conversation in which the GUI is modified after it is opened. 
  52.  
  53.   Open the file AWNPipe:myGUI/xc. 
  54. Write a Window definition line to the pipe.
  55. 'title "My First gui" defaultgadgets modify'
  56. The modify keyword tells the pipe you want to be able to modify this GUI later.
  57. The line read from the pipe should be
  58. 'ok window'
  59.  
  60. Write a Gadget definition line to the pipe. 
  61. 'button gadgettext "testbutton"
  62. The line read from the pipe should be
  63. 'ok 1'
  64.  
  65. Write a Gadget definition line to the pipe. 
  66. 'checkbox gadgettext "tryme"
  67. The line read from the pipe should be
  68. 'ok 2'
  69.  
  70. Write open command line to the pipe.
  71. 'open'
  72. The line read from the pipe should be
  73. 'ok window'
  74.  
  75. After the window is opened you get your first chance to modify it. We want to disable the button so we send the following line.
  76. 'ID 1 disable 1 refresh'
  77. The button is specified with 'ID 1' and 'disable 1' disables it. The refresh at the end tells the pipe to refresh the button so the changes show.
  78. The line read from the pipe should be
  79. 'ok'
  80. If the response does not start with 'ok' an error occurred.
  81.  
  82. We also want the check mark to show as selected so we write the line
  83. 'ID 2 selected 1'
  84. The button is specified with 'ID 1' and 'selected 1' turns causes it to be checked (the checkmark showing in the box). The refresh at the end tells the pipe to refresh the button so the changes show.
  85. The line read from the pipe should be
  86. 'ok'
  87.  
  88. WE have finished modifying the GUI for now so we send a line to tell the pipe we are finished sending modify instruction and want to read an event from the pipe.
  89. 'continue'
  90. The line read from the pipe should be
  91. 'ok'
  92.  
  93. Now you read an events from the pipe.  
  94.  
  95. If the checkbox is selected you get the line
  96. 'gadget 2 0'
  97. The user selected the checkbox gadget, it is now unchecked. We want enable the button gadget. AFTER SENDING AN EVENT THE PIPE STARTS READING MODIFY INSTRUCTIONS AGAIN. We send the following modify line to the pipe.
  98. 'ID 1 disable 0 refresh'
  99. The button is specified with 'ID 1' and 'disable 0' enables it. The refresh at the end tells the pipe to refresh the button so the changes show.
  100. The line read from the pipe should be
  101. 'ok'
  102. WE have finished modifying the GUI for now so we send a line to tell the pipe we are finished sending modify instruction and want to read another event.
  103. 'continue'
  104. The line read from the pipe should be
  105. 'ok'
  106.  
  107. If the checkbox is selected a second time you get the line
  108. 'gadget 2 1'
  109. The 1 at the end tells you the checkbox is now selected. We want to disable the button gadget so we send the line
  110. 'ID 1 disable 1 refresh'
  111. The line read from the pipe should be
  112. 'ok'
  113. WE have finished modifying the GUI for now so we send a line to tell the pipe we are finished sending modify instruction and want to read another event.
  114. 'continue'
  115. The line read from the pipe should be
  116. 'ok'
  117.  
  118. If the button is selected you get the line
  119. 'gadget 1 0'
  120. WE do not want to modify anything at this time but we still need to send the continue line so the pipe will stop looking for modify lines and send us another event.
  121. 'continue'
  122. The line read from the pipe should be
  123. 'ok'
  124.  
  125. when the GUI window is closed you get the line
  126. 'close 0'
  127. The window is closed but we can still send modify commands. For example we could read the final state of the gadgets. In this case we will do nothing but send the continue line.
  128. 'continue'
  129. The line read from the pipe should be
  130. 'ok'
  131. Any further reads from the pipe return EOF.
  132.  
  133. You keep reading an event then sending modify commands until the end of file is received. You could also close the pipe after the close event is read. 
  134.  
  135.